package org.example.project.search.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.example.project.search.data.Suggestion

/**
 * 记录内容单项
 */
@Composable
fun RecordItem(item: Suggestion) {

    if (item.type == Suggestion.TYPE_GUESS.toLong()) {
        GuessRecordItem(item)
    }
    else {

        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(5.dp),
            verticalAlignment = Alignment.Top
        ) {
            Column(
                modifier = Modifier
                    .padding(4.dp)
            ) {
                Img(12.dp)
            }
            println("${item.name} play ")
            when (item.type) {
                Suggestion.TYPE_DOORPLATE.toLong() -> {
                    PlaceRecordItem(item)
                }

                Suggestion.TYPE_POI.toLong() -> {
                    PoiRecordItem(item)
                }

                Suggestion.TYPE_METRO_STATION.toLong() -> {
                    MetroRecordItem(item)
                }

                Suggestion.TYPE_BUS_STATION.toLong() -> {
                    BusRecordItem(item)
                }

                Suggestion.TYPE_BUS_LINE.toLong(), Suggestion.TYPE_METRO_LINE.toLong() -> {
                    LineRecordItem(item)
                }

                Suggestion.TYPE_MINI_APP.toLong() -> {
                    MiniAppRecordItem(item)
                }

                Suggestion.TYPE_CITY.toLong() -> {
                    CityRecordItem(item)
                }

                Suggestion.TYPE_LATLNG_SEARCH.toLong() -> {
                    LatLonRecordItem(item)
                }

                Suggestion.TYPE_SEARCH_DIRECT.toLong() -> {
                    SearchDirectRecordItem(item)
                }

                else -> {
                    BasicRecordItem(item)
                }
            }
            println("${item.name} success")
        }

    }

}